{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#All the needed libraries for the project\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import sys\n",
    "from pandas import DataFrame\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "from sklearn.preprocessing import OneHotEncoder\n",
    "from sklearn.model_selection import train_test_split\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "scaled_ble= pd.read_csv('datasets/Scaled_BLE_RSSI.csv')\n",
    "distance = pd.read_csv('datasets/iBeacon_Distance.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = scaled_ble.values\n",
    "y = distance.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(18460,)"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = np.array(X)\n",
    "X = np.reshape(X, (-1, ))\n",
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18460"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = np.array(y)\n",
    "y = np.reshape(y, (-1, ))\n",
    "y.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = np.reshape(X, (-1,1 ))\n",
    "y = np.reshape(y, (-1,1 ))\n",
    "X[20,0] == 0.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2043,)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = []\n",
    "for i in range(0,X.shape[0]):\n",
    "    if X[i,0] == 0.0:\n",
    "        index.append(i)\n",
    "\n",
    "\n",
    "X = np.delete(X, index)\n",
    "y = np.delete(y, index)\n",
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "StandardScaler(copy=True, with_mean=True, with_std=True)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.preprocessing import StandardScaler\n",
    "scaler = StandardScaler()\n",
    "print( scaler.fit(X.reshape(-1, 1)))\n",
    "Xs = scaler.transform(X.reshape(-1, 1))\n",
    "from sklearn.preprocessing import quantile_transform\n",
    "Xs = quantile_transform(X.reshape(-1, 1), n_quantiles=5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XucXHWZ5/HPN00HOogGhuCQJhBl\nY9QhQrSFOHEVEQzrONry8saIl1lXXEcdRSezMLKDzsSFNavujDoz4ogy6qKC2OA1slxEUZDGBBrQ\nKBe5dBhphRaRJnQ6z/xxToVOpy6nu+tUnarzfb9e/eqqU6eqnpNOnafO7/L8FBGYmVl5LWh3AGZm\n1l5OBGZmJedEYGZWck4EZmYl50RgZlZyTgRmZiXnRGBmVnK5JQJJ+0j6saQbJd0i6YPp9s9JulPS\nlvTnqLxiMDOzxvbK8bW3A8dFxMOSeoEfSPp2+tj6iLgox/c2M7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ICKmgG2SrqgT2kZJHya5algzLd7/ljb7HA/8FXACSbmDz0raRJI4XgG8TdKRdY77\nMUmXAq+S9FWSE/V3p8V7vqRH4Vt+AAACC0lEQVQVJOUUeuvEOdOLgecA16elRfpIkufXgadK+jjw\nzWnvZSXnRGCFkJ6YryKpHjpCUiDwJ1Qvu3sa8CvgSJKr2mqL0Ah4V0Rs2m1jsrxh1roq64GLgb8k\nacd/zrR4R4ARSZ8H7iQtf502aZ0HnJd2XB/R4D0uAM5M470kIibT7X8PXBkRr0ybe66q8twd7H5V\nv0/6W8D5EXHGzCekiWkd8A7gNcB/bRCflYCbhqzt0tE208snHwXcRdI8slTSc9P99tPjJcTvS+vQ\nv4GkSNlMm4C3p527SHpaeiVxNfC6tL38YNLqnbWk7/EPwAJJ6yQ9QdKxVWKtrLlbeb8/JFn4aLTB\n4V9JcqXyDh5vFiI9xspz31zjub8kWeoQJevZPiXdfjnJVcZB6WMHSDos7YRfEBFfBf5n5blmviKw\nIngC8PG0TX0HSbXFU9Omk9emj/WR9A8cD/wT8FVJryY5kf6+ymv+K8lonp8oaR8ZIxmh8zXgOGAE\n+DnwvUbBRURI2gD8dfoafy3pU2k8v+fxE/VLgH+QVLlCWR8R/y7p6XVee2faLPRqkiRV8WGSpqH3\nArWar75KUqZ4C0kZ55+nr3mrpDOB76b9F5MkiWYC+Oy0Po09rhisnFx91Mys5Nw0ZGZWck4EZmYl\n50RgZlZyTgRmZiXnRGBmVnJOBGZmJedEYGZWck4EZmYl9x/ugSsBQ57R9QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X,y)\n",
    "plt.ylabel('Distance')\n",
    "plt.xlabel('Scaled RSSI Values')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 4.6168186 ,  6.66831094,  6.66831094, ...,  2.58230729,\n",
       "        2.58230729,  2.58230729])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestRegressor\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.tree import DecisionTreeRegressor\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(Xs, y,\n",
    "                                                    test_size=0.15,\n",
    "                                                   random_state=4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DecisionTreeRegressor(criterion='mse', max_depth=7, max_features=None,\n",
       "           max_leaf_nodes=None, min_impurity_decrease=0.0,\n",
       "           min_impurity_split=None, min_samples_leaf=1,\n",
       "           min_samples_split=2, min_weight_fraction_leaf=0.0,\n",
       "           presort=False, random_state=None, splitter='best')"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regr_rf = DecisionTreeRegressor(max_depth=7,criterion='mse')\n",
    "regr_rf.fit(X_train.reshape((-1,1)), y_train.reshape((-1,)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1.15384615])"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regr_rf.predict(0.9996)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.25641986022935048"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regr_rf.score(X_test.reshape((-1,1)), y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
